# -*- coding: utf-8 -*-
import torch
from torch.autograd import Variable
'''
x = Variable(torch.Tensor([5]), requires_grad = True)
y = Variable(torch.Tensor([5]), requires_grad = True)
z = 2 * x * x + y + 4
z.backward()
print('dz/dx: {}'.format(x.grad.data))
print('dz/dy: {}'.format(y.grad.data))
'''

x = Variable(torch.ones(2,2), requires_grad = True)
y = x + 2
z = x * x * 2
out = z.mean()
out.backward()
print(x.grad.data)
